import {
	requestNoAuth,
	request
} from '../../lib/java110/java110Request.js';
import url from '../../constant/url.js';


// #ifdef H5

	const WexinPayFactory = require('../../lib/java110/factory/WexinPayFactory.js');

// #endif

/**
 * 查询活动列表
 */
export function getRecommendProduct(dataObj) {
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryMainCategory,
				method: "GET",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						let _products = res.data.data;
						resolve(_products);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

/**
 * 查询拼团产品
 */
export function getGroupBuyProduct(dataObj) {
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryGroupBuyProduct,
				method: "GET",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						let _products = res.data.data;
						resolve(_products);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

/**
 * 查询产品
 */
export function getProduct(dataObj) {
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryProduct,
				method: "GET",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						let _products = res.data.data;
						resolve(res.data);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
};

/**
 * 查询产品
 */
export function queryGroupProduct(dataObj) {
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryGroupProduct,
				method: "GET",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.data.code == 0) {
						let _products = res.data.data;
						resolve(res.data);
						return;
					}
					reject(res.data.msg);
				},
				fail: function(e) {
					reject();
				}
			});
		})
};

/**
 * 搜索产品
 */
export function searchProduct(dataObj) {
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.searchProduct,
				method: "GET",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						let _products = res.data.data;
						resolve(_products);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
};

//查询商品分组
export function queryProductCategory(_data){
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryShopGoodsCatagory,
				method: "GET",
				data: _data,
				//动态数据
				success: function(res) {
					let _json = res.data;
					if (_json.code == 0) {
						resolve(_json.data);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

export function queryShopAppraise(_dataObj){
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.queryShopAppraise,
				method: "GET",
				data: _dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						let _appraisets = res.data;
						resolve(_appraisets);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

export function queryGroupGoods(_dataObj){
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.listProductGroup,
				method: "GET",
				data: _dataObj,
				//动态数据
				success: function(res) {
					if (res.data.code == 0) {
						let _appraisets = res.data.data;
						resolve(_appraisets);
						return;
					}
					reject(res.data.msg);
				},
				fail: function(e) {
					reject();
				}
			});
		})
}


export function queryProductSeckill(_dataObj){
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.listProductSeckill,
				method: "GET",
				data: _dataObj,
				//动态数据
				success: function(res) {
					if (res.data.code == 0) {
						let _appraisets = res.data.data;
						resolve(_appraisets);
						return;
					}
					reject(res.data.msg);
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

export function querySeckillProduct(_dataObj){
	return new Promise(
		(resolve, reject) => {
			requestNoAuth({
				url: url.querySeckillProduct,
				method: "GET",
				data: _dataObj,
				//动态数据
				success: function(res) {
					if (res.data.code == 0) {
						let _appraisets = res.data.data;
						resolve(_appraisets);
						return;
					}
					reject(res.data.msg);
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

